package com.etoak.stock.config;

import com.etoak.stock.pojo.vo.StockInfoConfig;
import com.etoak.stock.utils.IdWorker;
import com.etoak.stock.utils.ParserStockInfoUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author by 孙有泽
 * @Date 2024/10/1013:48
 * @Description 定义公共的bean
 */
@Configuration
@EnableConfigurationProperties({StockInfoConfig.class})
public class CommonConfig {
    /*
     * 基于雪花算法的配置
     * */
    @Bean
    public IdWorker idWorker(){
        /*
         * 参数1 机器id
         * 参数2 机房id
         * 机房和机器编号一般有运维人员进行唯一标识
         * */
        return new IdWorker(1L,2L);
    }

    @Bean
    public ParserStockInfoUtil parserStockInfoUtil(){
        return new ParserStockInfoUtil(idWorker());
    }
}
